/*
 *更新 击倒玩家也生效.
 *特征 Boomer拍打玩家， 发出咚咚响，和屏幕震动效果.
 */
 
#include <sourcemod>
#include <sdktools>



#define PLUGIN_VERSION "1.0"

public Plugin:myinfo =
{
	name = "[L4D2]Boomer攻击反馈",
	author = "ヾ藤野深月ゞ",
	description = "提取依据RPG中TANK攻击玩家时的受击反馈",
	version = PLUGIN_VERSION,
	url = "https://gitee.com/sweet-and-sour-bombs/adfvsdsd"
}

public OnPluginStart()
{
	/* Event */
	HookEvent("player_hurt",			Event_PlayerHurt, EventHookMode_Pre);

}



/* 玩家受伤 */
public Action:Event_PlayerHurt(Handle:event, String:event_name[], bool:dontBroadcast)
{
	new victim = GetClientOfUserId(GetEventInt(event, "userid"));
	new String:WeaponUsed[256];
	GetEventString(event, "weapon", WeaponUsed, sizeof(WeaponUsed));
	//if(IsValidPlayer(victim) && GetClientTeam(victim) == 2 && !IsFakeClient(victim))
	if(IsValidPlayer(victim) && GetClientTeam(victim) == 2)
	{
		if(StrEqual(WeaponUsed, "boomer_claw") || StrEqual(WeaponUsed, "boomer_vomit"))
		{
			PrintToChatAll("\x04[提示]\x03Boomer\x05杀死了\x03%s\x05.",  GetTrueName(victim));
			ForcePlayerSuicide(victim);
		}
	}
	return Plugin_Handled;
}




stock bool:IsValidPlayer(Client)
{
	//if (Client < 1 || Client > MaxClients) return false;
	//if (!IsClientConnected(Client) || !IsClientInGame(Client)) return false;
	return true;
}


char[] GetTrueName(int client)
{
	char sName[32];
	int Bot = IsClientIdle(client);

	if(Bot != 0)
		FormatEx(sName, sizeof(sName), "闲置:%N", Bot);
	else
		GetClientName(client, sName, sizeof(sName));
	return sName;
}

int IsClientIdle(int client) 
{
	if (!HasEntProp(client, Prop_Send, "m_humanSpectatorUserID"))
		return 0;

	return GetClientOfUserId(GetEntProp(client, Prop_Send, "m_humanSpectatorUserID"));
}

